﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Asdo.Controls
{
    [ValueConversion(typeof(Thickness), typeof(CornerRadius))]
    public class ThicknessToCornerRadius : IValueConverter
    {
        #region Implementation of IValueConverter

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var t = value as Thickness?;
            if (targetType == typeof(CornerRadius) && t != null)
            {
                return new CornerRadius(t.Value.Left, t.Value.Top, t.Value.Right, t.Value.Bottom);
            }
            return new CornerRadius(0);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}